<template>
  <div class="container">
    <div class="tabs">
      <input type="radio" id="radio-1" name="tabs" checked />
      <label class="tab" for="radio-1" v-on:click="onChange('blue')"
        >Bule</label
      >
      <input type="radio" id="radio-2" name="tabs" />
      <label class="tab" for="radio-2" v-on:click="onChange('dark')"
        >Dark</label
      >
      <input type="radio" id="radio-3" name="tabs" />
      <label class="tab" for="radio-3" v-on:click="onChange('pink')"
        >Pink</label
      >
      <input type="radio" id="radio-4" name="tabs" />
      <label class="tab" for="radio-4" v-on:click="onChange('light')"
        >Light</label
      >
      <span class="glider"></span>
    </div>
  </div>
</template>
<script setup>
function onChange(value) {
  document.documentElement.setAttribute('theme-mode', value)
  localStorage.setItem('theme-mode', value)
}
</script>
<style lang="scss" scoped>
.container {
  display: flex;
  align-items: center;
  justify-content: center;
}
.tabs {
  display: flex;
  position: relative;
  background-color: #fff;
  box-shadow:
    0 0 1px 0 rgba(#0b0b0b, 0.15),
    0 6px 12px 0 rgba(#060606, 0.15);
  padding: 0.75rem;
  border-radius: 99px; // just a high number to create pill effect
  * {
    z-index: 2;
  }
}

input[type='radio'] {
  display: none;
}

.tab {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  width: 150px;
  font-size: 1.25rem;
  font-weight: 500;
  border-radius: 99px; // just a high number to create pill effect
  cursor: pointer;
  transition: color 0.15s ease-in;
}

input[type='radio'] {
  &:checked {
    & + label {
      color: var(--primary-color);
      & > .notification {
        background-color: var(--primary-color);
        color: #fff;
      }
    }
  }
}

input[id='radio-1'] {
  &:checked {
    & ~ .glider {
      transform: translateX(0);
    }
  }
}

input[id='radio-2'] {
  &:checked {
    & ~ .glider {
      transform: translateX(100%);
    }
  }
}

input[id='radio-3'] {
  &:checked {
    & ~ .glider {
      transform: translateX(200%);
    }
  }
}

input[id='radio-4'] {
  &:checked {
    & ~ .glider {
      transform: translateX(300%);
    }
  }
}

.glider {
  position: absolute;
  display: flex;
  height: 34px;
  width: 150px;
  background-color: var(--secondary-color);
  z-index: 1;
  border-radius: 99px; // just a high number to create pill effect
  transition: 0.25s ease-out;
}

@media (max-width: 700px) {
  .tabs {
    transform: scale(0.6);
  }
}
</style>
